<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">

  <title>Document</title>

  <style>

    * {
      margin: 0;
      padding: 0;
    }
    .box {
      width: 500px;
      height: 300px;
      background-color: lavenderblush;
      margin: 100px auto;
    }
    .nav {
      display: flex;
    }
    .nav li{
      list-style: none;
      width: 100px;
      height: 60px;
      background-color: lightgoldenrodyellow;
      text-align: center;
    }

    .nav li:hover {
      background-color: lightgreen;
    }

    .img li{
      list-style: none;
      width: 500px;
      height: 240px;
      background-color: lightyellow;
      display: none;
    }

    .img .show {
      display: block;
    }
  </style>
</head>

<body>

  <div class="box">
    <ul class="nav">
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
    </ul>

    <ul class="img">
      <li class="show"><img src="https://via.placeholder.com/500x240/0000FF" alt=""></li>
      <li><img src="https://via.placeholder.com/500x240/0099FF" alt=""></li>
      <li><img src="https://via.placeholder.com/500x240/9900FF" alt=""></li>
      <li><img src="https://via.placeholder.com/500x240/9999FF" alt=""></li>
      <li><img src="https://via.placeholder.com/500x240/1111FF" alt=""></li>
    </ul>
  </div>


  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script>


      //这里面不能放箭头函数！！！！！！！
      //箭头函数没有this
      //$('.nav>li').mouseenter(()=>{
      $('.nav>li').mouseenter(function(){
        var index = $(this).index();
        // console.log(index)
        let $li = $('.img>li').eq(index);
        $li.siblings().removeClass('show')
        $li.addClass('show')
      })
      


    // $(".nav>li").mouseenter(function () {
    //     // 1.3获取当前移出选项卡的索引
    //     var index = $(this).index();
    //     console.log(index)
    //     // 1.4根据索引找到对应的图片
    //     var $li = $(".img>li").eq(index);
    //     // 1.5隐藏非当前的其它图片
    //     $li.siblings().removeClass("show");
    //     // 1.6显示对应的图片
    //     $li.addClass("show");
    // });    
  </script>

</body>

</html>